<template>
  <div class="mod-noc__texh">
    <el-form :inline="true">
      <el-form-item>
        <el-button @click="getDataList()">{{ $t("query") }}</el-button>
      </el-form-item>
      <el-form-item>
        <el-button type="info" @click="exportHandle()">{{ $t("export") }}</el-button>
      </el-form-item>
      <el-form-item>
        <el-button v-if="hasPermission('noc:texh:save')" type="primary" @click="addOrUpdateHandle()">{{ $t("add") }}</el-button>
      </el-form-item>
      <el-form-item>
        <el-button v-if="hasPermission('noc:texh:delete')" type="danger" @click="deleteHandle()">{{ $t("deleteBatch") }}</el-button>
      </el-form-item>
      <!-- 管理服务内容 -->

      <el-form-item>
        <el-button type="primary" @click="showManageSer">管理服务内容</el-button>
      </el-form-item>
    </el-form>
    <el-table @current-change="handleSelectionChange" highlight-current-row v-loading="dataListLoading" :data="dataList" border style="width: 100%">
      <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
      <el-table-column prop="id" label="主键" header-align="center" align="center"></el-table-column>
      <el-table-column prop="tplId" label="展会" header-align="center" align="center"></el-table-column>
      <el-table-column prop="fullName" label="全称" header-align="center" align="center"></el-table-column>
      <el-table-column prop="startTime" label="开始时间" header-align="center" align="center"></el-table-column>
      <el-table-column prop="endTime" label="结束时间" header-align="center" align="center"></el-table-column>
      <el-table-column prop="orderEndTime" label="订购结束时间" header-align="center" align="center"></el-table-column>
      <el-table-column prop="status" label="展会状态" header-align="center" align="center">
        <template #default="scope">
          <div style="display: flex; align-items: center">
            <span style="margin-left: 10px">{{ scope.row.status == "0" ? "关闭" : "开启" }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">
        <template v-slot="scope">
          <el-button v-if="hasPermission('noc:texh:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">{{ $t("update") }}</el-button>
          <el-button v-if="hasPermission('noc:texh:delete')" type="text" size="small" @click="deleteHandle(scope.row.id)">{{ $t("delete") }}</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total" layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle" @current-change="pageCurrentChangeHandle"> </el-pagination>
    <!-- 弹窗, 新增 / 修改 -->
    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    <manage-ser ref="manageSer" :exhId="selectedExhId"></manage-ser>
  </div>
</template>

<script lang="ts">
import useView from "@/hooks/useView";
import { defineComponent, reactive, toRefs } from "vue";
import AddOrUpdate from "./texh-add-or-update.vue";
import ManageSer from "./texh-add.vue";
export default defineComponent({
  components: {
    AddOrUpdate,
    ManageSer
  },

  setup() {
    const state = reactive({
      getDataListURL: "/noc/texh/page",
      getDataListIsPage: true,
      exportURL: "/noc/texh/export",
      deleteURL: "/noc/texh",
      deleteIsBatch: true,
      dataForm: {}
    });
    return { ...useView(state), ...toRefs(state) };
  },
  data() {
    return {
      selectedExhId: 0,
      manageSerVisible: false
    };
  },
  methods: {
    handleSelectionChange(val: { tplId: number }) {
      this.selectedExhId = val.tplId;
    },
    showManageSer() {
      if (this.selectedExhId) {
        this.$refs.manageSer.dialogVisible = true;
      } else {
        this.$message.error("请选择展会");
      }
    }
  },
  watch: {}
});
</script>
<style scoped></style>
